package diandiansong.library.http;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by act on 2016/3/21.
 * state code
 */
public class ErrorCode {


    /**
     * 从 8000, 000开始编号，避免与服务器上等 code 冲突
     */
    public static final int ERROR_TOAST = -80000001;
    public static final int ERROR_NET = -80000002;
    public static final int ERROR_PARSE = -80000003;
    public static final int ERROR_UNKNOW = -80000004;
    public static final int ERROR_PARAMS = -80000005;

    public static final int ERROR_TIME_OUT = -80000006;

    ///////////////////////////////////////////////////////////////////////////
    // Server
    ///////////////////////////////////////////////////////////////////////////

    public static void handle(Context context, int errorCode, String errorMsg){
        switch (errorCode){
            case ERROR_NET:
                Toast.makeText(context,"网络异常",Toast.LENGTH_SHORT);
                break;
            case ERROR_PARSE:
                Toast.makeText(context,"解析错误",Toast.LENGTH_SHORT);
                break;
        }
    }


}